﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace LambdaExamples
{
    class Program
    {
        static int Square(int number)
        {
            return number * number;
        }

        static int Sum(int a, int b)
        {
            return a + b;
        }
        static void Main(string[] args)
        {
            Func<int, int> myDel = n => n*n;
            Func<int, int,int> myDel2 = (a,b) => a+b;

            Console.WriteLine(myDel(5));
            Console.WriteLine(myDel2(4,5));
            Console.WriteLine();
            Console.WriteLine();

            List<Book> books = new List<Book>
            {
                new Book("Колобок", 10),
                new Book("Анна Каренина", 20),
                new Book("Репка", 30)
            };

            var results = books.FindAll(b => b.Price < 30);
            foreach (var book in results)
            {
                Console.WriteLine(book.Name);
            }
        }

    }

    class Book
    {
        public int Price { get; set; }
        public string Name { get; set; }

        public Book(string name, int price)
        {
            Name = name;
            Price = price;
        }
    }
}
